<template>
	<view>
		<view class="kehu-item">
			<view class="kehu-left">
				<view class="touxiang-box">
					<image :src="imgurl+'/touxiang.png'" mode="aspectFit" class="touxiang-image"></image>
					<view v-if="oper_Id=='男'">
						<image :src="imgurl2+'/nanxing.png'" mode="aspectFit" class="xingbie"></image>
					</view>
					<view v-else>
						<image :src="imgurl2+'/nuxing.png'" mode="aspectFit" class="xingbie"></image>			
					</view>
				</view>
				
				<view class="kehu-message">
					<view class="kehu-message-top">
						<view class="kehu-name">
							<!-- 李逵之 -->
							<!-- <input type="text" style="width: 200upx;" clearable class="uni-input"  value="" v-model="news_Tit" placeholder="" /> -->
							{{news_Tit}} 
						</view>
						
						<view v-if="effe_Flg=='查看'"><!-- 实名认证状态 -->
							<image :src="imgurl2+'/shi.png'" mode="aspectFit" class="label-image"></image>
						</view>
						<view v-else><!-- 实名认证状态 -->
							<image :src="imgurl2+'/shi.png'" style="filter:grayscale(100%);" mode="aspectFit" class="label-image"></image>
						</view>
						
						<view v-if="show_Flg=='查看'"><!-- 合格投资者认证状态 -->
							<image :src="imgurl2+'/he.png'" mode="aspectFit" class="label-image"></image>
						</view>
						<view v-else><!-- 合格投资者认证状态 -->
							<image :src="imgurl2+'/he.png'" style="filter:grayscale(100%);" mode="aspectFit" class="label-image"></image>
						</view>
						
						<view v-if="check_Flg=='查看'"><!-- 专业投资者认证状态 -->
							<image :src="imgurl2+'/zhuan.png'" mode="aspectFit" class="label-image"></image>
						</view>
						<view v-else><!-- 专业投资者认证状态 -->
							<image :src="imgurl2+'/zhuan.png'" style="filter:grayscale(100%);" mode="aspectFit" class="label-image"></image>
						</view>
						<!-- <image src="http://ai.ylcaifu.com/appimg/images/5.0-%E6%88%91%E7%9A%84-%E7%90%86%E8%B4%A2%E5%B8%88/5.1-%E6%88%91%E7%9A%84%E5%AE%A2%E6%88%B7%EF%BC%88CRM%EF%BC%89/android/drawable-xhdpi/he.png" mode="aspectFit" class="label-image"></image> -->
					</view>
					<view class="kehu-message-bottom">
						<image :src="imgurl2+'/xingjikehu.png'" mode="aspectFit"></image>
						<view v-if="tag_Sign!='无'" class="star">
							<!--一星客户  -->
							{{tag_Sign}}星客户
						</view>
						<view v-else class="star">
							<!-- 未评级 -->
						</view>
						
					</view>
				</view>
			</view>
				
		</view>
		<view class="kehu-box">
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/dianhuan.png'" mode=""></image>
					手机号
				</view>
				<view class="right">
					<view class="">
						<!-- 13109-90930221 -->
						{{author}}
						<!-- <input type="text" style="width: 200upx;" clearable class="uni-input"  value="" v-model="author" placeholder="" /> -->
					</view>
					<image @click="toCallPhone(author)" :src="imgurl+'/dianhuan.png'" mode="" class="kehu-right"></image>
					
				</view>
				
			</view>
			<view class="row">
				<view class="left" style="width: 160upx;">
					<image class="left-image" :src="imgurl+'/xingbei.png'" mode=""></image>
					性别
				</view> 
				<view class="right">
					{{oper_Id}}
					<!-- 女 -->
				</view>
				<!-- <view style="width: 450upx;margin-left: 200upx;" class="uni-list">
					<view class="uni-list-cell">
						<view class="uni-list-cell-left">
							请选择 <label class="iconfont"> &#xe640;</label>
						</view>
						<view class="uni-list-cell-db">
							<picker @change="bindPickerChange" :value="index" :range="array">
								<view class="uni-input">{{oper_Id}}</view>
							</picker>
						</view>
					</view>
				</view> -->
				
			</view>
			
			<view class="row">
				<view class="left"  style="width: 160upx;">
					<image class="left-image" :src="imgurl+'/shengre.png'" mode=""></image>
					生日
				</view>
				<view class="right">
					<!-- 1999-10-10 -->
					{{date}}
				</view>
				<!-- <view class="uni-list" style="width: 450upx;margin-left: 200upx;">
					<view class="uni-list-cell">
						<view class="uni-list-cell-left">
							
							请选择 <label class="iconfont"> &#xe640;</label>
						</view>
						<view class="uni-list-cell-db">
							<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
								<view class="uni-input">{{date}}</view>
							</picker>
						</view>
					</view>
				</view> -->
			</view> 
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/dingwei.png'" mode=""></image>
					所在地区
				</view>
				
				<view class="right">
					{{addr}}
				</view>
				<!-- <view class="right">
					<view class="">
						<input type="text" style="width: 200upx;" clearable class="uni-input"  value="" v-model="addr" placeholder="" />
					</view>
				</view> -->
				
			</view>
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/biaoqian.png'" mode=""></image>
					标签
					<image  :src="imgurl2+'/he.png'" mode="aspectFit" class="label-image"></image>
					
				</view>
				<view class="right">
					<view class="btn">
						添加
					</view>
				</view>
				
			</view>
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/shimingrenzheng.png'" mode=""></image>
					实名认证
				</view>
				<view class="right">
					<view class="btn" @click="toShiMingRenZheng">
						{{effe_Flg}}
					</view>
					<!-- <view v-else class="btn yirenzheng">
						已认证
					</view> -->
				</view>
				
			</view>
			
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/chuangye.png'" mode=""></image>
					风险测评
				</view>
				<view class="right">
					<view class="btn" @click="hegeAuthentication">
						{{isRisk}}
					</view>
					<!-- <view v-else class="btn yirenzheng">
						已认证
					</view> -->
				</view>
				 
			</view>
			
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/hege.png'" mode=""></image>
					合格投资者认证
				</view>
				<view class="right">
					<view  class="btn" @click="toHeGeTouZiZheRenZheng">
						{{show_Flg}}
					</view>
					<!-- <view v-else class="btn yirenzheng">
						已认证
					</view> -->
				</view>
				
				
			</view>
			
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/chuangye.png'" mode=""></image>
					专业投资者认证
				</view>
				<view class="right">
					<view class="btn" @click="toZhuanYeTouZiZheRenZheng">
						{{check_Flg}}
					</view>
					<!-- <view v-else class="btn yirenzheng">
						已认证
					</view> -->
				</view>
				
			</view>
			
			
			
			<view class="row">
				<view class="left">
					<image class="left-image" :src="imgurl+'/chuangye.png'" mode=""></image>
					客户持仓
				</view>
				<view class="right">
					<view class="btn" @click="toKehuchicang">
						查看
					</view>
				</view>
				
			</view>
		<!-- --合格投资者认证
			去认证
			查看
			--实名认证||专业投资者认证
			去认证：没有认证过  --申请
			@待审核：提交认证资料，但还没有通过审核 --查看
			@已认证：审核通过之后变为查看              --查看
			审核驳回  --编辑 -->
		</view>
	</view>
</template>

<script>
	import global from '../../../../components/tool/homePageQuery.vue';
	import global_wyx from '../../../../components/tool/licaishiwyx.vue';

	export default { 
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				imgurl:'http://ai.ylcaifu.com/appimg/images/5.0-%E6%88%91%E7%9A%84-%E7%90%86%E8%B4%A2%E5%B8%88/5.1.4-%E5%AE%A2%E6%88%B7%E8%AF%A6%E6%83%85/android/drawable-xhdpi',
				imgurl2:'http://ai.ylcaifu.com/appimg/images/5.0-%E6%88%91%E7%9A%84-%E7%90%86%E8%B4%A2%E5%B8%88/5.1-%E6%88%91%E7%9A%84%E5%AE%A2%E6%88%B7%EF%BC%88CRM%EF%BC%89/android/drawable-xhdpi',
				token:uni.getStorageSync('token_key'),
				news_Tit:'',
				oper_Id:'',
				effe_Flg:'',
				show_Flg:'',
				check_Flg:'',
				tag_Sign:'',
				author:'',
				array: ['男', '女'],
				current:'',
				index: 0,
				date:'19901010',
				addr:'北京市朝阳区团结虎嘉铭中心B座',
				news_Id:'',//客户号
				customerInfo:{'customerName':'','customerId':''},
				isRisk:'',
				score:'',
				
				
			};
		},onLoad(e) {
			this.news_Id = e.news_Id;

			/* 
			this.news_Tit = e.news_Tit;
			this.oper_Id = e.oper_Id;
			this.effe_Flg = e.effe_Flg;
			this.show_Flg = e.show_Flg;
			this.check_Flg = e.check_Flg;
			this.tag_Sign = '无';
			this.date = e.news_TitChtld;//生日
			this.addr = e.news_Source;//地址 
			console.log("星级别客户空值判断---"+JSON.stringify(this.news_Id))
			this.author = e.author;*/
			//console.log("客户详情------------"+JSON.stringify(this.news_Tit)+"------"+JSON.stringify(e)+"~~~~")
			uni.request({
				method: 'POST',
				url: global.api.queryCustomerDetail,
				header : {'content-type':'application/x-www-form-urlencoded'},
				data: {
					token: this.token,
					customerId: this.news_Id
				},
				dataType: 'json',
				success: (res) => {
					console.log("客户详情查询---"+JSON.stringify(res.data.code)+"-----"+JSON.stringify(res.data.message));
					console.log("客户详情查询----"+JSON.stringify(res.data.data.customerList));
					var list = new Array();
					list=res.data.data.customerList;
					console.log("客户详情长度-----------"+list.length);
					if(list.length!=0){
						for(var i=0;i<list.length;i++) {
							this.news_Tit = list[i].news_Tit;
							this.oper_Id = list[i].oper_Id;
							this.effe_Flg = list[i].effe_Flg;
							this.show_Flg = list[i].show_Flg;
							this.check_Flg = list[i].check_Flg;
							this.tag_Sign = list[i].tag_Sign;
							this.news_Id = list[i].news_Id;
							this.date = list[i].news_TitChtld;//生日
							this.addr = list[i].news_Source;//地址
							this.author = list[i].author;//手机号
							this.isRisk = list[i].show_User;//是否测评
							this.score = list[i].news_ShowType;//风险测评得分
							uni.setStorageSync('whetherRisk',this.isRisk);
							console.log("是否风险测评结果-----"+this.isRisk)
							console.log("--合格投资者状态-----"+this.show_Flg)
							console.log("--实名认证状态-----"+this.effe_Flg)
							console.log("--专业投资者状态-----"+this.check_Flg)

						} 
					}
					
				},
				fail: (res) => {
				
				},
				complete: (res) => {
					//停止当前页面下拉刷新。
					//uni.hideNavigationBarLoading();
					uni.stopPullDownRefresh();
				}
			})
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods:{
			toKehuchicang(item){
				uni.request({
					url: global_wyx.api.lcs_ishavechicang,
					method: 'POST',
					data: {
						token:this.token,
						custid:this.news_Id
					},
					header : {'content-type':'application/x-www-form-urlencoded'},
					success: res => {
						var resultData = res.data.data;
						if(parseInt(resultData)>0){
							uni.navigateTo({
								url: '../../wodechicang/wodechicang?news_Id='+this.news_Id,
								success: res => {},
								fail: () => {},
								complete: () => {}
							});
						}else{
							uni.showToast({
								title: '客户未购买过产品',
								mask: false,
								icon:'none',
								duration: 1500
							});
						}
						console.info("持仓数目："+resultData)
					},
					fail: () => {},
					complete: () => {}
				});
				
// 				uni.request({
// 					url: '../../../wodechicang/wodechicang',
// 					method: 'POST',
// 					header : {'content-type':'application/x-www-form-urlencoded'},
// 					data: {},
// 					success: res => {},
// 					fail: () => {},
// 					complete: () => {}
// 				});
			},
			toCallPhone(phoneNo){
				uni.makePhoneCall({
					phoneNumber: phoneNo //仅为示例
				});
			},
			hegeAuthentication(){
				if(this.isRisk =='去测评'){//去测评
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/fenxianceping/fengxianceping?customerNo='+this.news_Id,
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}else{//查看测评结果
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/fenxianceping/cepingjieguo?customerNo='+this.news_Id+"&cpscore="+this.score,
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}
				
			},
			toShiMingRenZheng:function(res){
				if(this.effe_Flg == '查看'){
					console.log('现在是【查看】状态');
					this.customerInfo.customerName=this.news_Tit;
					this.customerInfo.customerId=this.news_Id;
					uni.setStorageSync("customerInfo",this.customerInfo.customerName);
					uni.setStorageSync("customerId",this.customerInfo.customerId);
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/chakan/shiming-look',
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				} else if(this.effe_Flg == '去认证') {//申请页面
					console.log('现在是【去认证】状态');
					this.customerInfo.customerName=this.news_Tit;
					this.customerInfo.customerId=this.news_Id;
					uni.setStorageSync("customerInfo",this.customerInfo.customerName);
					uni.setStorageSync("customerId",this.customerInfo.customerId);
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/shimingrenzheng/shimingrenzheng?customerNo='+this.news_Id,
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}else if(this.effe_Flg == '审核驳回') {//编辑页面
					console.log('现在是【审核驳回】状态');
					this.customerInfo.customerName=this.news_Tit;
					this.customerInfo.customerId=this.news_Id;
					uni.setStorageSync("customerInfo",this.customerInfo.customerName);
					uni.setStorageSync("customerId",this.customerInfo.customerId);
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/bohui/shimingrenzheng-bohui',
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}
				
			},
			toHeGeTouZiZheRenZheng:function(res){
				this.customerInfo.customerId=this.news_Id;
				uni.setStorageSync("customerId",this.customerInfo.customerId);
				if(this.show_Flg == '查看'){
					console.log("==============合格投资者【查看】页面");
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/hegerenzheng/hegerenzheng',
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}else{//去认证页面
					console.log("合格投资者认证------");
					if(this.effe_Flg=='查看'){//已做实名认证
						uni.navigateTo({
								url: '../../../product/productYemian/productDetail/simuYuyue/shimingrenzheng/qualifiedCertification?customerNo='+this.news_Id,
								success: res => {},
								fail: () => {},
								complete: () => {}
						});
					}else{
						uni.showToast({
							title: '请先进行实名认证',
							icon: 'none',
							duration:2000,
							success: res => {},
							fail: () => {},
							complete: () => {}
						});
						return;
					}
					
				}
				
			},
			toZhuanYeTouZiZheRenZheng:function(res){
				this.customerInfo.customerId=this.news_Id;
				uni.setStorageSync("customerId",this.customerInfo.customerId);
				if(this.check_Flg == '查看'){
					console.log("--------------专业投资者认证【查看页】");
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/chakan/zhuanyerenzheng-look',
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}else if(this.check_Flg == '去认证'){//申请页面
					if(this.effe_Flg=='查看'){//已做实名认证
						console.log("专业投资者认证------");
						uni.navigateTo({
								url: '../../../product/productYemian/productDetail/simuYuyue/shimingrenzheng/professionalCertification?customerNo='+this.news_Id,
								success: res => {},
								fail: () => {},
								complete: () => {}
						});
					}else{
						uni.showToast({
							title: '请先进行实名认证',
							icon: 'none',
							duration:2000,
							success: res => {},
							fail: () => {},
							complete: () => {}
						});
						return;
					}
				}else if(this.check_Flg == '审核驳回'){//编辑页面
					console.log("专业投资者认证------");
					uni.navigateTo({
							url: '../../../product/productYemian/productDetail/simuYuyue/shimingrenzheng/professionalCertification?customerNo='+this.news_Id,
							success: res => {},
							fail: () => {},
							complete: () => {}
					});
				}
				
			},
			bindPickerChange: function(e) {
				//console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
				this.oper_Id = this.array[this.index];
			},
			bindDateChange: function(e) {
				this.date = e.target.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		},
		onNavigationBarButtonTap(){
			uni.navigateTo({
					url: '../xinjiankehu/xiugaikehu?news_Id='+this.news_Id,
					success: res => {},
					fail: () => {},
					complete: () => {}
			});
		}
		 
	}
</script>

<style>
.kehu-item{
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0 20upx;
		border-bottom: 1px solid rgb(0,0,0,0.05) ;
		justify-content: space-between;
		height: 80px;
		background: rgb(255,255,255);
		
	}
	.kehu-left,.kehu-message-bottom{
		display: flex;
		flex-direction: row;
		align-items: center;
		
	}
	.touxiang-box{
		position: relative;
		margin-right: 20upx;
	}
	.touxiang-box .xingbie{
		position: absolute;
		width: 14px;
		height: 12px;
		
		
		bottom: 0;
		right: 0;
	}
	.kehu-left .touxiang-image{
		width: 45px;
		height: 45px;
		
	}
	
	.kehu-message-top{
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 16px;
		line-height: 30px;
		
	}
	.label-image{
		width: 16px;
		height: 16px;
		margin-left: 8upx;
	}
	.kehu-message-bottom{
		line-height: 15px;
		font-size:10px ;
	}
	.kehu-message-bottom image{
		width: 12px;
		height: 9px;
	}
	.star{
		
		color:#C49C5A ;
	}
	.kehu-box{
		padding: 0 30upx;
		margin-top: 5px;
		background: rgb(255,255,255);
	}
	.row {
		height: 54px;
		border-bottom: 1px solid rgba(238,238,238,1);
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
	.row input{
		
	}
	.left {
		display: flex;
		flex-direction: row;
	
		align-items: center;
		font-size: 15px;
		margin-right: 20upx;
		
	}
	
	.questionBox {
		display: flex;
		flex-direction: row;
		justify-content: center;
		width: 100%;
		padding: 40upx 0;
		text-align: center;
		margin-top: 50%;
	
	}
	.label {
		margin:0 10upx;
	}
	.right{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		color: #CCCCCC;
	}
	.kehu-right {
		width: 25px;
		height: 25px;
		margin-left: 10upx;
	}
	.left-image{
		height: 18px;
		width: 18px;
		margin-right: 20upx;
	}
	.btn{
		line-height: 22px;
		border: 1px solid #C49C5A;
		border-radius: 22upx;
		padding: 0 15upx;
		color: #C49C5A;
	}
	.yirenzheng{
		color: #CCCCCC;
		border: 1px solid #CCCCCC;
	}
</style>
